package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCDemo5 {
    public static void main(String[] args) {
        try (Connection conn = DBUtil.getConnection();) {
            Statement statement = conn.createStatement();
            String sql = "SELECT  id,name,salary,title  "
                    + " FROM teacher";
            ResultSet rs = statement.executeQuery(sql);
            while (rs.next()) {
                int id = rs.getInt(1);
                String name = rs.getString(2);
                double salary = rs.getInt(3);
                String title = rs.getString(4);
                System.out.println(id + " " + name + " " + salary + " " + title);
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
